package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@SuppressWarnings({"unchecked", "rawtypes"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;


	/**
	 * 查询首页：获取分类
	 * @return
	 */
	@GetMapping("/getBaseCategoryList")
	public Result getBaseCategoryList(){
		return Result.ok(baseCategoryService.getBaseCategoryList());
	}

	/**
	 * 查询标签数据
	 * @param category1Id
	 * @return
	 */
	@GetMapping("/findAttribute/{category1Id}")
	public Result findAttribute(@PathVariable Long category1Id){
		return Result.ok(baseCategoryService.findAttribute(category1Id));
	}

	/**
	 * 首页：根据一级分类id获取三级分类top7 SQL
	 * @param category1Id
	 * @return
	 */
	@GetMapping("/findTopBaseCategory3/{category1Id}")
	public Result findTopBaseCategory3(@PathVariable Long category1Id){
		return Result.ok(baseCategoryService.findTopBaseCategory3(category1Id));
	}


	/**
	 * 首页 搜索
	 * 指定一级下所有二级和三级标签
	 * @param category1Id
	 * @return
	 */
	@GetMapping("/getBaseCategoryList/{category1Id}")
	public Result getBaseCategoryList(@PathVariable("category1Id") Long category1Id){
		return Result.ok(baseCategoryService.getBaseCategoryList(category1Id));
	}




}

